#include "rclcpp/rclcpp.hpp"

using namespace std::chrono_literals;

class PublisherNode : public rclcpp::Node
{
public:
    PublisherNode(std::string name) : Node(name)
    {
        RCLCPP_INFO(this->get_logger(), "pulisher node 01");
    }

    void start()
    {
        RCLCPP_INFO(this->get_logger(), "start this node not use spin...");
        std::string in_data_str;
        std::cin >> in_data_str;
        RCLCPP_INFO(this->get_logger(), "cin=%s", in_data_str.c_str());
    }
};

int main(int argc, char **argv)
{
    // 初始化ros2的C++接口
    rclcpp::init(argc, argv);
    // 建立节点对象
    auto node = std::make_shared<PublisherNode>("publisher_01");
    node->start();
    // 运行节点，检测退出信号
    rclcpp::spin(node);
    // 销毁节点并关闭C++接口
    rclcpp::shutdown();

    return 0;
}